package pt.utl.ist.ginger3d.domain;

import java.util.HashMap;
import java.util.Map;

import pt.utl.ist.ginger3d.domain.types.DerivedType;
import pt.utl.ist.ginger3d.domain.types.IBlockType;
import pt.utl.ist.ginger3d.domain.types.NumericType;
import pt.utl.ist.ginger3d.domain.types.PlaceHolderType;
import pt.utl.ist.ginger3d.domain.types.StringType;

public class BlockTypeHandler {

	private static BlockTypeHandler instance = new BlockTypeHandler();
	
	public Map<String, IBlockType> types;
	
	public static BlockTypeHandler getInstance() {
		return instance;
	}
	
	private BlockTypeHandler() {
		types = new HashMap<String, IBlockType>();
		
		NumericType numericType = new NumericType();
		types.put("int", numericType);
		types.put("uint", numericType);
		types.put("short", numericType);
		types.put("ushort", numericType);
		types.put("long", numericType);
		types.put("ulong", numericType);
		
		StringType stringType = new StringType();
		types.put("str", stringType);
		
		PlaceHolderType placeHolderType = new PlaceHolderType();
		types.put("place-holder", placeHolderType);
	}

	public IBlockType getType(String typeId) {
		return types.get(typeId);
	}

	public void addType(String typeName, String baseType, Map<String, String> properties) {
		types.put(typeName, new DerivedType(getType(baseType), properties));
	}
	
}
